<?php
declare(strict_types=1);

namespace app\platform\middleware;
class Auth
{
    public function handle($request, \Closure $next)
    {
        // 前置中间件
        $noAuth = !strstr($request->pathinfo(), "login") && !strstr($request->pathinfo(), "verify");
        if (empty(session(config('merchant.session_merchant'))) && $noAuth) {
            // return redirect((string)url('login/index'));
            $url = url("login/index");
            echo exit('<script>top.location.href="' . $url . '"</script>');
        }

        return $next($request);
        // 后置中间件
    }

    public function end(\think\Response $response)
    {

    }
}
